package com.tiansu.reborn.wanda.modules.executor.entity;

import java.io.Serializable;

import lombok.Data;

//前台通用返回数据结构
@Data
public class FacadeResponse implements Serializable{
    private static final long serialVersionUID = 1L;
    private int errcode;
    private String errmsg;
    private Object data;

    public FacadeResponse(int code, String msg) {
        this.setErrcode(code);
        this.setErrmsg(msg);
    }

    public static FacadeResponse error() {
        return error(500, "未知异常，请联系管理员");
    }

    public static FacadeResponse error(String msg) {
        return error(500, msg);
    }

    public static FacadeResponse error(int code, String msg) {
        FacadeResponse r = new FacadeResponse(code,msg);
        return r;
    }

    public static FacadeResponse error(Exception e) {
        FacadeResponse r = new FacadeResponse(500,e.getMessage());
        return r;
    }

    public static FacadeResponse ok(int code, String msg) {
        FacadeResponse r = new FacadeResponse(code,msg);
        return r;
    }
    public static FacadeResponse ok(int code) {
        FacadeResponse r = new FacadeResponse(code,"success");
        return r;
    }

    public static FacadeResponse ok(String msg) {
        FacadeResponse r = new FacadeResponse(200,msg);
        return r;
    }

    public static FacadeResponse ok() {
        return new FacadeResponse(200,"success");
    }
}
